﻿/*  
 Copyright 2010 The 'Tribe.Blog' development team  
 (http://tribecache.codeplex.com/team/view)

 This library is licensed under the Ms-PL Microsoft Public License.  You should 
 have received a copy of the license along with the source code.  If not, an online copy
 of the license can be found at http://tribecache.codeplex.com/license.
*/

using System;
using Tribe.Cache.Enum;

namespace Tribe.Cache
{
    /// <summary>
    ///  ICache
    /// </summary>
    public interface ICache
    {
        /// <summary>
        /// Will either get or put an item into the cache dependant on the objects current state in the cache.
        /// If an object does not exist or has expired then a new instance will be saved to the cache and then returned.
        /// If an object exists and has not expired then the cached instance will be returned
        /// </summary>
        /// <typeparam name="T">Return type - will be inferred from the return type of the delegates encapsulated method</typeparam>
        /// <param name="cacheId">The identifier that will be used to retrieve the object from the cache</param>
        /// <param name="getItemCallback">() => class.Method(params) </param>
        /// <param name="spanToCache">TimeSpan to cache the item for</param>
        /// <returns></returns>
        T Get<T>(string cacheId, Func<T> getItemCallback, TimeSpan spanToCache);
        ///<summary>
        /// Will either get or put an item into the cache dependant on the objects current state in the cache.
        /// If an object does not exist or has expired then a new instance will be saved to the cache and then returned.
        /// If an object exists and has not expired then the cached instance will be returned
        /// </summary>
        /// <typeparam name="T">Return type - will be inferred from the return type of the delegates encapsulated method</typeparam>
        /// <param name="cacheId">The identifier that will be used to retrieve the object from the cache</param>
        /// <param name="getItemCallback">() => class.Method(params) </param>
        /// <param name="spanToCache">TimeSpan to cache the item for</param>
        ///<param name="cacheExpiration">Sets how the item should cache should expire</param>
        ///<returns></returns>
        T Get<T>(string cacheId, Func<T> getItemCallback, TimeSpan spanToCache, CacheExpiration cacheExpiration);
        /// <summary>
        /// Removes an item from the cache
        /// </summary>
        /// <param name="cacheId">The identifier that will be used to remove the object from the cache</param>
        void Delete(string cacheId);
        /// <summary>
        /// Clears all items in the cache
        /// </summary>
        void Clear();
        /// <summary>
        /// Counts the number of items in the cache
        /// </summary>
        /// <returns>int</returns>
        int Count();
    }
}
